﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace CapaPresentacion.Converters
{
    class BooleanToDateConverter : System.Windows.Data.IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DateTime? dateValue = value as DateTime?;

            if (dateValue.Value.ToShortDateString() == "01/01/0001" || dateValue.Value == null)
            {
                return DateTime.Now; 
            }
            else
            {
                return dateValue;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DateTime? dateValue = value as DateTime?;

            return dateValue;
        }










    }
}
